#ifndef SWITCHDELEGATE_H
#define SWITCHDELEGATE_H

#include "comui_global.h"

#include <QStyledItemDelegate>
#include <QCheckBox>

class COMUISHARED_EXPORT SwitchDelegate : public QStyledItemDelegate
{
    Q_OBJECT
public:
    SwitchDelegate(QObject *parent, int column);

    void paint(QPainter *painter, const QStyleOptionViewItem &option,
              const QModelIndex &index) const override;
    bool editorEvent(QEvent *event, QAbstractItemModel *model,
                    const QStyleOptionViewItem &option,
                    const QModelIndex &index) override;

signals:
    void stateChanged(const QModelIndex &index, bool checked) const;

private:
    QPoint m_mousePoint;  // 鼠标位置
    QScopedPointer<QCheckBox> m_checkBox;
    int m_delegateColumn;
};


#endif // SWITCHDELEGATE_H
